package com.ztom.daily.n2022.m4;

import java.util.Arrays;

/**
 * 最小差值 1
 * <p>
 * https://leetcode-cn.com/problems/smallest-range-i/
 *
 * @author ZhangTao
 */
public class Day30SmallestRangeI {

    public int smallestRangeI(int[] nums, int k) {
        int minNum = Arrays.stream(nums).min().getAsInt();
        int maxNum = Arrays.stream(nums).max().getAsInt();
        return maxNum - minNum <= 2 * k ? 0 : maxNum - minNum - 2 * k;
    }
}
